package com.newcoin.chat.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Value("${mapping-path}")
    private String mappingPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        /**
         * 将系统目录下的文件映射到/stattic/目录下  这样就可以使用http://localhost:8080/static/xxx/xx.jpg访问啦
         */
//        registry.addResourceHandler("/static/**").addResourceLocations("file:D://static/"); //dev路径
        registry.addResourceHandler("/static/**").addResourceLocations("file:" + mappingPath);//生产及测试路径

    }
}
